package com.ptu.spzx.manager.controller;


import com.github.pagehelper.PageInfo;
import com.ptu.spzx.manager.service.SysUserService;
import com.ptu.spzx.model.dto.system.AssginDeptDto;
import com.ptu.spzx.model.dto.system.AssginRoleDto;
import com.ptu.spzx.model.entity.system.SysUser;
import com.ptu.spzx.model.vo.common.Result;
import com.ptu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/ac/system/sysDeptUser")
public class SysDeptUserController {
    @Autowired
    private SysUserService sysUserService;
    //用户分配部门
    //保持分配数据
    @PostMapping("/doAssign")
    @PreAuthorize("@permissionService.hasPermission('system:sysDeptUser:doAssign')")
    public Result doAssign(@RequestBody AssginDeptDto assginDeptDto){
        sysUserService.doAssignDept(assginDeptDto);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/getUserBudeptId")
    @PreAuthorize("@permissionService.hasPermission('system:sysDeptUser:getUserBudeptId')")
    public Result getUserBudeptId(@RequestParam Integer deptId,
                                  @RequestParam Integer pageNum,
                                  @RequestParam Integer pageSize){
        PageInfo<SysUser> sysUserPageInfo=sysUserService.getUserBudeptId(deptId,pageNum,pageSize);
        return Result.build(sysUserPageInfo,ResultCodeEnum.SUCCESS);
    }
}
